package util
{
	import flash.external.ExternalInterface;
	
	import mx.utils.URLUtil;
	
	/**
	 * Class to parse the URL - entered into the Browser.
	 * 
	 * All Parameters in the URL the confirm to
	 * URL?paramName=paramValue&param2Name=param2Value
	 * will be parsed and the parameters are stored in
	 * the params Object as
	 * key : paramName  value : paramValue
	 * key : param2Name value : param2Value
	 * 
	 * @author jbaeck
	 * 
	 */
	public class UrlParser
	{
		public var params:Object = new Object();
		public var url:String;
		public var queryString:String;
		
		public function UrlParser()
		{
			parse();				
		}
		
		/**
		 * Parses the URL - for parameters.
		 *  
		 * Stores the complete url in the member url and the parameters in the params object.
		 */
		public function parse():void
		{
			url = ExternalInterface.call("window.location.href.toString");
			queryString = 	ExternalInterface.call("window.location.search.substring", 1);
			
			if(queryString)
				params = URLUtil.stringToObject(queryString,"&");
		}
		
	}
}